#include "../include/Convert.h"

namespace ZY {

    Convert::Convert()
    {
        //ctor
    }

    Convert::~Convert()
    {
        //dtor
    }

    int Convert::toInt32( const string& _str)
    {
        int num = 0;
        num = atoi(_str.c_str());
        return num;
    }

    int16_t Convert::toInt16(const  string& _str)
    {
        int16_t num = 0;
        num = atoi(_str.c_str());
        return num;
    }

    int8_t Convert::toInt8(const string& _str)
    {
        int8_t num = 0;
        num = atoi(_str.c_str());
        return num;
    }

    unsigned Convert::toUInt32(const string& _str)
    {
        unsigned int num = 0;
        num = atoi(_str.c_str());
        return num;
    }

    int64_t Convert::toInt64(const string& _str)
    {
        int64_t num = 0;
        num = atol(_str.c_str());
        return num;
    }

    string Convert::toString(const int num)
    {
        char buff[16]={0};
        sprintf(buff,"%d",num);
        return buff;
    }

    string Convert::toString(const int8_t num)
    {
        char buff[16]={0};
        sprintf(buff,"%d",num);
        return buff;
    }

    string Convert::toString(const int16_t num)
    {
        char buff[16]={0};
        sprintf(buff,"%d",num);
        return buff;
    }

    string Convert::toString(const int64_t num)
    {
        char buff[16]={0};
        sprintf(buff,"%ld",num);
        return buff;
    }


}
